//
//  YCHouseServiceViewController.m
//  YCSchool
//
//  Created by gmall on 16/5/6.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  住宿服务

#import "YCHouseServiceViewController.h"
#import "YCHouseServiceDetailViewController.h"
#import "YCServiceButton.h"

@interface YCHouseServiceViewController ()<UITableViewDelegate,UITableViewDataSource>

/** tableView */
@property (nonatomic, strong) UITableView *tableView;
/** 数据  */
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation YCHouseServiceViewController


- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.yc_width, self.view.yc_height-64) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.backgroundColor = [UIColor whiteColor];//[UIColor yc_colorWithUInt:0xf7f7f7];
        _tableView.tableFooterView = [[UIView alloc] init];
    }
    return _tableView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self yc_addBackBarButtonItem];
    self.navigationItem.title = @"住宿服务";
    [self.view addSubview:self.tableView];
    // 拨打客服电话
    YCServiceButton *callServiceButton = [YCServiceButton buttonWithType:UIButtonTypeCustom];
    [callServiceButton setImage:[UIImage imageNamed:@"shopCover_mobilePhone"] forState:UIControlStateNormal];
    callServiceButton.backgroundColor = [UIColor yc_colorWithRed:86 Green:200 Blue:14];
    [callServiceButton setTitle:@"拨打订房电话" forState:UIControlStateNormal];
    [callServiceButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [callServiceButton addTarget:self action:@selector(callServiceBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:callServiceButton];
    
    [callServiceButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-45);
        make.centerX.equalTo(self.view);
        make.width.equalTo(@150);//284px
        make.height.equalTo(@35);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        cell.detailTextLabel.textColor = [UIColor redColor];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
        cell.textLabel.textColor = [UIColor darkGrayColor];
        cell.textLabel.font = [UIFont systemFontOfSize:16];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.text = @"普通房间";
    cell.detailTextLabel.text = @"¥ 158";
    return cell;
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YCLogFunc
    YCHouseServiceDetailViewController *houseDetailVc = [[YCHouseServiceDetailViewController alloc] init];
    [self.navigationController pushViewController:houseDetailVc animated:YES];
}

#pragma mark - 点击事件
- (void)callServiceBtnClick:(UIButton *)button
{
    YCLogFunc
    // 用封装的actionSheet
    LXActionSheet *actionSheet = [[LXActionSheet alloc] initWithCancelButtonTitle:@"取消" otherButtonTitlesArray:@[@"拔打 0871-68120277"]];
    UIButton *callButton =[actionSheet buttonAtIndex:1];
    callButton.titleLabel.font = [UIFont systemFontOfSize:17];
    [callButton setTitleColor:[UIColor yc_colorWithUInt:0x00b4ff] forState:UIControlStateNormal];
    [actionSheet showInView:self.view mask:YES maskColor:[UIColor colorWithWhite:0.3 alpha:1]  click:^(NSUInteger index, LXActionSheet *sheet) {
        if (index == 1) {
            if ([@"tel://087168120277" yc_canOpenURL]) {
                [@"tel://087168120277" yc_openURL];
            }
        }
    } cancel:^(NSUInteger index, LXActionSheet *sheet) {
        
    }];
}


@end
